import {
    Method
} from 'axios';

export const parseQueryStr = (
    data: any,
    decode: boolean = true
):string => {
    const keys = Object.keys(data).sort();
    return keys.map(key => {
        let value = data[key];
        value = decode ? encodeURIComponent(value) : value;
        return `${key}=${value}`;
    }).join(`&`);
}

//检测当前是否为post
export const checkPost = (
    method?:Method
):boolean => {
    const methods: any = ['post','POST','put','PUT'];
    return methods.includes(method);
}

